<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\GoPager;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CouponCategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '优惠券分类管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="coupon-category-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <p> <?= Html::a("领券数量同步", ['sync'], ['class' => 'btn btn-success']) ?>
        <?= Html::a("优惠券同步", ['load-data'], ['class' => 'btn btn-success', 'data' => [
                'confirm' => '谨慎点击，会重置优惠券原始数量，用户领取数不会变',
                'method' => 'post',
            ],]) ?></p>
    <?php  echo $this->render('_search', ['model' => $searchModel]); ?>



    <?= GridView::widget([
        'dataProvider' => $dataProvider,
//        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\CheckboxColumn'],


            'title',
            'mark_id',
            'origin_num',
            'use_num',

            ['attribute'=>'created_at','value'=>function($model){

                return date("Y-m-d H:i:s",$model->created_at);
            }],

            ['attribute'=>'status','value'=>function($model){

                return $model->status?'有效':'失效';
            }],
            //'updated_at',
            //'local_mark_id',

            ['class' => 'yii\grid\ActionColumn'],
        ],
        'pager' =>[
            'class' => GoPager::className(),
            'firstPageLabel' => '首页',
            'prevPageLabel' => '<',
            'nextPageLabel' => '>',
            'lastPageLabel' => '尾页',
            'goPageLabel' => true,
            'totalPageLable' => '共x页',
            'goButtonLable' => 'GO',
            'maxButtonCount' => 5
        ]
    ]); ?>
</div>
